import numpy as np

# 简单的强化学习环境
class Environment:
    def __init__(self):
        self.state = 0

    def step(self, action):
        reward = 1 if action == 0 else -1
        self.state = 1 - self.state
        return self.state, reward

# 策略梯度算法
env = Environment()
policy = np.array([0.5, 0.5])

for episode in range(10):
    state = 0
    done = False
    while not done:
        action = np.random.choice([0, 1], p=policy)
        state, reward = env.step(action)
        print(f"Episode {episode}, Action: {action}, Reward: {reward}")